#ifndef SIP_SESSIONMGR_HPP__
#define SIP_SESSIONMGR_HPP__

#include "WTResipDll/SipWTResipDllItf.hpp"
#include "WTSXSipService/SipWTSXServiceItf.hpp"
#include "WTSXSipService/SipHandleMgr.hpp"

#include <map>
#include <boost/thread/shared_mutex.hpp>

namespace wtsxsip{


class CSipSessionBase;
class CSipTranSession;
class CSipDlgSessionBase;

class CSipSessionMgr
{
public:

    CSipSessionMgr(void);

    virtual ~CSipSessionMgr(void);

    CSipTranSession* createSession(wtsip::ISipClnTransaction& clnTran, wtsip::CapSipMessage request);

    CSipTranSession* createSession(wtsip::ISipSrvTransaction& srvtran, wtsip::CapSipMessage request);

    CSipDlgSessionBase* createDlgSession(wtsip::ISipDialogBase& dlg, 
        const wtsip::SUri& tarconst, ISipDlgSessionBase::EDlgType type);

    CSipDlgSessionBase* createDlgSession(wtsip::ISipDialogBase& dlg, wtsip::ISipSrvTransaction& srvtran, 
        wtsip::CapSipMessage request, ISipTranSession*& pTran);

    bool insertSession(CSipSessionBase* session);

    CSipSessionBase* matchSession(const uint32_t sid) const;

    bool destroySession(const uint32_t sid);

private:

    CSipHandleMgr m_handleMgr;

    std::map<uint32_t, CSipSessionBase*> m_sessions;

    mutable boost::shared_mutex m_SessionsMutex;
};



}//namespace
#endif


